package fr.greta.centre.dao;

import static org.junit.Assert.*;

import java.sql.SQLException;
import java.util.List;

import org.junit.Test;

import fr.greta.centre.metier.Candidat;

public class CandidatDAOImplTest {
	
	@Test
	public void testFindByEmailTrouve() throws SQLException {
		CandidatDAOImpl dao = new CandidatDAOImpl();
		Candidat candidat = dao.findByEmailAndPassword("dupont@greta.com", "1234");
		assertNotNull(candidat);
		int expId = 1;
		assertEquals(expId, candidat.getId());
	}
	
	@Test
	public void testFindByEmailPasTrouve() throws SQLException {
		CandidatDAOImpl dao = new CandidatDAOImpl();
		Candidat c= dao.findByEmailAndPassword("dupont@grate.com", "245");
		assertNull(c);
	}
	@Test
	public void testFindAll() throws SQLException {
		CandidatDAOImpl dao = new CandidatDAOImpl();
		List<Candidat> lesCandidats = dao.findAll();
		assertNotNull(lesCandidats);
		assertFalse(lesCandidats.isEmpty());
		
	}
	
	public void findByKey() throws SQLException {
		CandidatDAOImpl dao = new CandidatDAOImpl();
		Candidat unCandidat = dao.findByKey(3);
		System.out.println("candidat de key 3");
		System.out.println(unCandidat.toString());
	}

}
